package chapter06

object Test16_TraitSelfType {
  def main(args: Array[String]): Unit = {
    val user = new RegisterUser("bob", "123456")
    user.insert

  }
}

//用户类
class User(val name: String, val password: String)

trait UserDao {
  //自身类型的定义
  _: User =>
  //向数据库插入数据
  def insert: Unit = println(s"insert into db: name=${this.name},password = ${this.password}...")
}

//定义注册用户
class RegisterUser(name: String, password: String) extends User(name, password) with UserDao